﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.WindowsServerSolutions.MediaStreaming;

namespace Gpf.Whs.YouTubeDownloader.CommSrv
{
    public static class WhsHelper
    {
#if DEBUG
        public static Dictionary<Guid, string> GetStreamingMediaFolders()
        {
            var folders = new Dictionary<Guid, string>();
            folders.Add(Guid.Parse("0bfaa19a-fe3f-4014-82e8-7ca1d109ad31"), "Music");
            folders.Add(Guid.Parse("08a85925-5bb7-4834-a2ce-2b9e152bfffe"), "Videos");

            return folders;
        }

        public static string GetFolderPath(Guid folderId)
        {
            return "c:\\temp\\";
        }
#endif

#if !DEBUG
        public static Dictionary<Guid, string> GetStreamingMediaFolders()
        { 
            var folders = new Dictionary<Guid, string>();
            
            var mediaManager = new MediaStreamingManager();
            foreach (var folder in mediaManager.GetSharedFolders())
            {
                folders.Add(folder.ID, folder.Name);
            }
            return folders;
        }

        public static string GetFolderPath(Guid folderId)
        {
            var mediaManager = new MediaStreamingManager();
            return mediaManager.GetSharedFolders().First(f => f.ID == folderId).Path;
        }
#endif
    }
}
